package com.eh.facade.facade.impl;

import com.eh.facade.facade.TheaterFacade;
import com.eh.facade.model.*;

/**
 * Created by David on 2016/4/30.
 */
public class HomeTheaterFacade implements TheaterFacade {

    private Amplifier amplifier;
    private DvdPlayer dvdPlayer;
    private PopcornPopper popcornPopper;
    private Projector projector;
    private Screen screen;
    private TheaterLights theaterLights;
    private Tuner tuner;

    public static class Builder {
        private Amplifier amplifier;
        private DvdPlayer dvdPlayer;
        private PopcornPopper popcornPopper;
        private Projector projector;
        private Screen screen;
        private TheaterLights theaterLights;
        private Tuner tuner;

        public Builder amplifier(Amplifier amplifier) {
            this.amplifier = amplifier;
            return this;
        }

        public Builder dvdPlayer(DvdPlayer dvdPlayer) {
            this.dvdPlayer = dvdPlayer;
            return this;
        }

        public Builder popcornPoper(PopcornPopper popcornPopper) {
            this.popcornPopper = popcornPopper;
            return this;
        }

        public Builder projector(Projector projector) {
            this.projector = projector;
            return this;
        }

        public Builder amplifier(Screen screen) {
            this.screen = screen;
            return this;
        }

        public Builder theaterLights(TheaterLights theaterLights) {
            this.theaterLights = theaterLights;
            return this;
        }

        public Builder amplifier(Tuner tuner) {
            this.tuner = tuner;
            return this;
        }

        public HomeTheaterFacade build() {
            return new HomeTheaterFacade(this);
        }
    }

    private HomeTheaterFacade(Builder b) {
        this.amplifier = b.amplifier;
        this.dvdPlayer = b.dvdPlayer;
        this.popcornPopper = b.popcornPopper;
        this.projector = b.projector;
        this.screen = b.screen;
        this.theaterLights = b.theaterLights;
        this.tuner = b.tuner;
    }

    @Override
    public void watchMovie() {
        popcornPopper.on();
        popcornPopper.pop();

        projector.on();
        projector.setInput();
        projector.wideScreenMode();

        amplifier.on();
        amplifier.setDvd();
        amplifier.setSurroundSound();
        amplifier.setVolumn();

        dvdPlayer.on();
        dvdPlayer.play();
    }

    @Override
    public void endMovie() {

    }
}
